class Picture < ActiveRecord::Base
  belongs_to :work
  has_attached_file :data, :styles => {  :thumb =>  { :geometry => "250x250>",
#                                                      :watermark_path => "#{RAILS_ROOT}/public/images/watermark125.png",
                                                      :position => "SouthEast"},
                                        :resized => { :geometry => "500x500>",
#                                                      :watermark_path => "#{RAILS_ROOT}/public/images/watermark250.png",
                                                      :position => "SouthEast"}
                                     },
#                          :processors => [:watermark],
                          :path => ":rails_root/public/:class/:attachment/:id/:style_:basename.:extension",
                          :url  => "/:class/:attachment/:id/:style_:basename.:extension"
  attr_protected :data_file_name, :data_file_size, :data_content_type
  validates_attachment_presence :data, :message => "请上传您的图片"
  validates_attachment_size :data, :less_than => 5.megabytes, :message => "图片不超过5m"
  validates_attachment_content_type :data, 
                                    :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg'  ,'image/png','image/bmp','image/gif'], 
                                    :message =>  "请上传jpeg,jpg,png,bmp,gif文件"
  
end
